/*=============================================================================
*
*   Copyright (C) 2020 All rights reserved.
*
*   Filename:		dirichlet_all.cpp
*
*   Author: Wang Zhecheng - wangzhecheng@yeah.net
*
*   Date: 2020-02-20 21:23
*
*   Last Editors: Wang Zhecheng - wangzhecheng@yeah.net
*
*   Last modified:	2020-03-25 00:15
*
*   Description:
*
=============================================================================*/

#include "../../include/fem.hpp"
#include "../../include/implicit_solver.hpp"
#include "../../include/incremental_load.hpp"
#include "../../include/model/model.hpp"
#include "../../include/solid.hpp"
#include "../../include/static_equation.hpp"

LOGGING_REGISTER()

void dirichlet_test(const std::string& input_file_name) {

  using namespace geoxfem;
  using namespace geoxfem::model;
  using namespace geoxfem::geometry;

  using MethodPolicy   = fem;
  using CouplePolicy   = solid;
  using DimensionType  = plane_strain;
  using EquationPolicy = static_equation;
  using SolvePolicy    = implicit_solver;
  using LoadPolicy     = incremental_load;
  using Model =
    geoxfem::model::Model<MethodPolicy, CouplePolicy, DimensionType,
                          EquationPolicy, SolvePolicy, LoadPolicy, mpl1>;

  /*  detail, trace, process, info, warning, debug, error }; */
  geoxfem::log::log_init(geoxfem::log::severity_level::error);

  io::DataParser<io::json> parser;
  parser.read(input_file_name);

  /* io::DataExtractor<Model> extractor; */
  /* extractor.init(parser); */

  io::DataWriter<Model, io::vtu> writer;
  writer.init(parser.getPath(), parser.getFileName());

  /* io::DataPloter                 ploter; */

  Model model;
  /* model.attach(extractor); */
  model.append(&writer);

  model.init(parser);
  model.buildProblem();
  model.solveProblem();

  return;
}

int main(int argc, char* argv[]) {

  std::string path = (argc < 2) ? "test/test_bc" : argv[1];

  for(size_t i = 1; i != 4; ++i)
    dirichlet_test(path
                   + (std::string("/dirichlet") + std::to_string(i) + ".json"));

  return 0;
}
